const mockData = require('../../utils/data.js')

Page({
  data: {
    searchKeyword: '',
    hotDestinations: [],
    allDestinations: [],
    selectedRegion: '中国',
    regions: ['中国', '亚洲', '欧洲', '北美洲', '大洋洲', '非洲', '南美洲', '南极洲']
  },
  
  onLoad() {
    this.loadDestinations()
  },
  
  loadDestinations() {
    this.setData({
      hotDestinations: mockData.hotDestinations,
      allDestinations: [
        {
          province: '湖北',
          cities: ['武汉', '宜昌', '襄阳', '十堰', '孝感', '恩施']
        },
        {
          province: '湖南',
          cities: ['长沙', '株洲', '湘潭', '常德', '岳阳', '衡阳', '湘西土家族自治区']
        }
      ]
    })
  },
  
  onSearchInput(e) {
    this.setData({
      searchKeyword: e.detail.value
    })
  },
  
  selectRegion(e) {
    const region = e.currentTarget.dataset.region
    this.setData({
      selectedRegion: region
    })
  },
  
  goToDestination(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/destination-detail/destination-detail?id=${id}`
    })
  }
})


